function [C] = ResidualInnerProductMatrix(images_name,denoising_function,crop_size,crop_location,in_memory)
%ResidualInnerProductMatrix calculates the inner prduct matrix between zero-mean
% noise residual used in Blind PRNU-based Image Clustering  described in [1]
%
% [C] = ResidualInnerProductMatrix(images_name,denoising_function,crop_size,crop_location)
%
% INPUT Specification:
%
% images_name  : a cell array with the path of the images
%
% denoising_function : 'bm3d'|'none'. Specify the denoising function
% to use to estimate the noise residual. If 'none' the images in images_name has to be
% mat file with grayscale noise residual of the images (saved as 'R').
% N.B. Images will be convert to grayscale
%
% crop_size : is a vector of type [p,q]. All the images will be cropped to
% pxq at crop_location. If p and q are both Inf, the maximum crop_size will
% be calculated.
%
% crop_location : 'center'|'upper-left'. The location where the image
% will be cropped.
%
% in_memory : true|false if true all the cropped noise residual will be
% stored in memory (can cause Out of Memory error)
%
% OUTPUT Specification:
%
% C              : a NxN matrix where Cij = sum(Ri.*Rj). Where Ri and Rj are
%                  the zero-mean noise residual of the images i and j
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% [1] F. Marra, G. Poggi, C. Sansone, L. Verdoliva.
%     Blind PRNU-based Image Clustering for Source Identification
%     IEEE Transactions on Information Forensics and Security, 2017
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright (c) 2017 Image Processing Research Group of University Federico II of Naples ('GRIP-UNINA').
% All rights reserved.
% this software should be used, reproduced and modified only for informational and nonprofit purposes.
%
% By downloading and/or using any of these files, you implicitly agree to all the
% terms of the license, as specified in the document LICENSE.txt
% (included in this package) and online at
% http://www.grip.unina.it/download/LICENSE_OPEN.txt
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Contact: francesco.marra@unina.it | Feb 2017
%          http://www.grip.unina.it
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
